//
//  ClassDetailCell.m
//  EducationAdminClient
//
//  Created by xuyingwei on 16/12/16.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "ClassDetailCell.h"
#import "Masonry.h"
#import "UIColor+CL.h"
#import "UIStyle.h"
@implementation ClassDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
    if(self){
        
        UIView *v = [self createUI];
        // UIView要加入到self.contentView上 不要加入到self
        [self.contentView addSubview:v];
        UIView *superview = self.contentView;
        UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
        [v mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(superview).insets(edge);
        }];
        
    }
    return self;
}


-(void)setEditIs:(BOOL)isEdit{
    if(isEdit){
        _titleText.editable = YES;
        _titleText.hidden = NO;
        _titleLabel.hidden = YES;
        
    }
    else{
        _titleText.editable = NO;
        _titleText.hidden = YES;
        _titleLabel.hidden = NO;
    }
    
}

-(UIView *)createUI{
    //    UIView *baseView = [[UIView alloc]init];
    
    UIView *v= [[UIView alloc]init];
    //    [baseView addSubview:v];
    v.userInteractionEnabled= YES;
    _title = [[UILabel alloc]init];
    [v addSubview:_title];
    
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(v.mas_left).offset(15);
        make.right.equalTo(v.mas_right).offset(-15);
        make.centerY.equalTo(v.mas_centerY);
    }];
//    [_title setContentHuggingPriority:UILayoutPriorityRequired
//                              forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
//    [_title setContentCompressionResistancePriority:UILayoutPriorityRequired
//                                            forAxis:UILayoutConstraintAxisHorizontal];
//    _title.text = @"未知";
//    _title.textColor =[UIColor colorWithHex:0x5c5c5c];
//    
//    self.titleText = [[CustomTextView alloc]init];
//    [v addSubview:_titleText];
//    //    _titleText.frame = CGRectMake(95, 10, 200, 30);
//    [_titleText mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(_title.mas_right).offset(38/2);
//        make.centerY.equalTo(v.mas_centerY);
//        make.height.equalTo(@(28));
//        make.right.equalTo(v.mas_right).offset(-30/2);
//    }];
//    _titleText.textColor = [UIColor colorWithHex:0x696969];
//    _titleText.font = [UIFont systemFontOfSize:16];
//    _titleText.bounces = NO;
//    self.contentView.userInteractionEnabled = NO;
//    
//    
//    _titleLabel = [[UILabel alloc]init];
//    [v addSubview:_titleLabel];
//    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        //#ifdef Main
//        
//        if([getUIStyle() isEqualToString:STYLE0]){
//            
//            make.left.equalTo(_title.mas_right).offset(38/2);
//            make.right.equalTo(v.mas_right).offset(-5);
//        }else{
//            //#elif Student
//            
//            make.left.equalTo(_title.mas_right).offset(50/2);
//            make.right.equalTo(v.mas_right).offset(-5);
//        }
//        //#elif Teacher
//        //        //    rootview
//        //        NSLog(@"老师端程序");
//        //#else
//        //
//        //        NSLog(@"都不是");
//        //#endif
//        make.centerY.equalTo(v.mas_centerY);
//        
//    }];
//    _titleLabel.numberOfLines = 0;
//    _titleLabel.hidden = YES;
//    _titleLabel.font = [UIFont systemFontOfSize:16];
//    _titleLabel.textColor = [UIColor colorWithHex:0x696969];
//    _titleLabel.textColor = [UIColor redColor];
//    
//    //#ifdef Main
//    
//    if([getUIStyle() isEqualToString:STYLE0]){
//        
//        _title.numberOfLines = 0;
//        
//        UIImageView *line =[[UIImageView alloc]init];
//        [v addSubview:line];
//        line.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
//        [line mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_title.mas_left);
//            make.right.equalTo(v.mas_right);
//            make.bottom.equalTo(v.mas_bottom);
//            make.height.equalTo(@(1));
//        }];
//    }else{
//        //#elif Student
//        _title.numberOfLines = 0;
//        
//        UIImageView *line =[[UIImageView alloc]init];
//        [v addSubview:line];
//        line.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
//        [line mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_title.mas_left);
//            make.right.equalTo(v.mas_right);
//            make.bottom.equalTo(v.mas_bottom);
//            make.height.equalTo(@(1));
//        }];
//        //    _titleLabel.backgroundColor = [UIColor greenColor];
//        //    _titleText.backgroundColor = [UIColor redColor];
//        //    _title.backgroundColor = [UIColor blueColor];
//        
//    }
//    
//    //#elif Teacher
//    //    //    rootview
//    //    NSLog(@"老师端程序");
//    //#else
//    //
//    //    NSLog(@"都不是");
//    //#endif
//    
//    
//    
//    _baseView1 = [[UIView alloc]init];
//    [v addSubview:_baseView1];
//    
//    UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
//    [_baseView1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(v).insets(edge);
//    }];
//    
//    _btnselectType = [[UIButton alloc]init];
//    [_baseView1 addSubview:_btnselectType];
//    
//    _editTextField = [[UITextField alloc]init];
//    [_baseView1 addSubview:_editTextField];
//    
//    [_btnselectType mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(_baseView1.mas_centerY);
//        make.width.equalTo(@(100));
//        make.left.equalTo(@(10));
//        make.height.equalTo(_baseView1.mas_height);
//    }];
//    
//    [_editTextField mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(_btnselectType.mas_centerY);
//        make.right.equalTo(_baseView1.mas_right);
//        make.left.equalTo(_btnselectType.mas_right);
//        make.height.equalTo(_baseView1.mas_height);
//    }];
//    
//    
//    _title.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
//    _title.font = [UIFont systemFontOfSize:30/2];
//    
//    _titleLabel.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
//    _titleLabel.font = [UIFont systemFontOfSize:32/2];
//    
//    _btnselectType.backgroundColor = [UIColor redColor];
//    
//    _baseView1.hidden = YES;
//    
//    //#if Student
//    _title.font = [UIFont systemFontOfSize:30/2];
//    _titleLabel.font = [UIFont systemFontOfSize:34/2];
//    //#endif
//    
//    
//    _btn =[[UILabel alloc]init];
//    [v addSubview:_btn];
//    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.title.mas_right).offset(25);
//        make.width.equalTo(@(100));
//        make.height.equalTo(@(35));
//        make.centerY.equalTo(v.mas_centerY);
//    }];
//    [_btn setBackgroundColor:[UIColor colorWithHex:0x5da6ff]];
//    _btn.layer.cornerRadius = 4.5;
//    _btn.font =[UIFont systemFontOfSize:15];
//    _btn.textColor =[UIColor whiteColor];
//    _btn.layer.masksToBounds = YES;
//    [_btn setText:@"点击拍照"];
//    _btn.textAlignment = NSTextAlignmentCenter;
//    
//    _la =[[UILabel alloc]init];
//    [v addSubview:_la];
//    [_la mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(_btn.mas_right).offset(10);
//        make.width.equalTo(@(100));
//        make.height.equalTo(@(35));
//        make.centerY.equalTo(v.mas_centerY);
//    }];
//    _la.font =[UIFont systemFontOfSize:15];
//    [_la setText:@"尚无附件"];
//    _btn.hidden = YES;
//    _la.hidden = YES;
    
//    self.canEnterNextView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"形状-19"]];
//    [v addSubview:_canEnterNextView];
//    [_canEnterNextView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(v.mas_centerY);
//        make.right.equalTo(v.mas_right).offset(-30/2);
//    }];
//    _canEnterNextView.hidden = YES;
    
    return v;
}


-(void)setShowType:(BOOL)show{
    if (show) {
        _baseView1.hidden = NO;
    }else{
        _baseView1.hidden = YES;
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
